package cn.itsource.org.mapper;

import cn.itsource.org.pojo.domain.Department;
import cn.itsource.org.query.DepartmentQuery;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 继承mapper接口
 */
public interface DepartmentMapper extends Mapper<Department> {
    //基础的curd通过继承得到
    List<Department> findPage(DepartmentQuery query);

    List<Department> findParentDepts();

                                                    // /3/8
    default List<Department> findByOldPath(String oldDirPath){

        Example example = new Example(Department.class);
        example.and().andLike("dirPath",oldDirPath+"%");

        //select * from t_department where dir_path like "/3/8%"
        return this.selectByExample(example);
    }
}
